import ComponentBase from "../BASE/ComponentBase";
import { gif } from "../BASE/spineANDgif/gif";
import Choose from "./choose";

const { ccclass, property } = cc._decorator;

@ccclass
export default class playimage extends ComponentBase {
    sd: boolean = false;
    @property(Number)
    p: number = null;

    @property(cc.SpriteAtlas)
    Atlas: cc.SpriteAtlas = null; // 通用图集

    start() {
        this.node.parent.children[2].color = cc.color(175, 175, 175);


       // this.node.parent.children[2].getComponent(gif).setMaterial(0,this.node.parent.children[2].getComponent(gif).getMaterials()[0])
        cc.find("Canvas/Main Camera/background/juese background").getComponent(Choose).pi.push(this);
    }

    changeui(num: string) {
      this.getComponent(cc.Sprite).spriteFrame = this.Atlas.getSpriteFrame(""+num);
      
      this.node.parent.children[1].getComponent(cc.Label).string = num;
        // this.node.parent.children[2].color = cc.color(255, 255, 255);
    }

    dao() {
        console.log("ad");
        if (this.p>0) {
        this.node.parent.children[2].getComponent(gif).setMaterial(0,this.node.parent.children[2].getComponent(gif).getMaterials()[1])
        }
     /*   this.schedule(() => {
            if (!this.sd) {
                cc.tween(this.node.parent.children[2]).to(0.4, { color: cc.color(255, 255, 255) }).start();
                setTimeout(() => {
                    cc.tween(this.node.parent.children[2]).to(0.4, { color: cc.color(175, 175, 175) }).start();
                }, 400);
            } else {
                cc.tween(this.node.parent.children[2]).stop();
                cc.tween(this.node.parent.children[2]).to(0.4, { color: cc.color(255, 255, 255) }).start();
            }
        }, 1);*/
    }

    qd() {
    if (this.p>0) {
        console.log(this.name)
        this.node.parent.children[2].getComponent(cc.Sprite).setMaterial(0,this.node.parent.children[2].getComponent(cc.Sprite).getMaterials()[0]) 
    }    
}
}